/**
 * Copyright European Commission's
 * Taxation and Customs Union Directorate-General (DG TAXUD).
 */
package com.eryos;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.eryos.bean.City;

/**
 * 
 * @author $Author: $
 * @version $Revision: $
 */
public abstract class ParametrizedReport extends FindLeBonCoinResultsTest {

	/** The Logger. */
	private static final Logger LOGGER = LoggerFactory
			.getLogger(ParametrizedReport.class);

	private static int cityId = 0;
	private final City city;
	private int level = 0;

	/**
	 * Default constructor.
	 */
	public ParametrizedReport(final String cityName, final int levelArg) {
		LOGGER.info("CityReport" + levelArg + "({})", cityName);
		city = new City(cityId, cityName);
		level = levelArg;
		cityId++;

		this.setTestName("CityReport" + level + "(" + cityName + ")");
		this.addTag(cityName);
		this.addTag("Z" + levelArg);
	}

	public void processCity() {
		LOGGER.info("processCity({})", city.getName());

		// Find list of results
		this.searchForCity(city);

		// Retrieve details for all results
		this.findDetails(city);
	}

	/**
	 * Prepare env. for test run.
	 * 
	 * @throws IOException
	 */
	public static void initClass() throws IOException {
		LOGGER.info("initClass()");

		// TODO
	}

	/**
	 * @return List cities to process.
	 */
	public static Collection<Object[]> getAllCities(String[] listOfCitites) {
		LOGGER.info("Initialize collection");
		List<Object[]> result = new ArrayList<Object[]>();

		for (String city : listOfCitites) {
			result.add(new Object[] { city });
		}

		return result;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Logger getLogger() {
		return LOGGER;
	}

	/**
	 * @return the level
	 */
	public int getLevel() {
		return level;
	}

	/**
	 * Sets the level.
	 * 
	 * @param level
	 *            the value to set
	 */
	public void setLevel(int level) {
		this.level = level;
	}

	/**
	 * @return the city
	 */
	public City getCity() {
		return city;
	}

}
